/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trunk.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import trunk.model.calendar.Event;

/**
 *
 * @author Karine
 */
@SuppressWarnings("serial")
public class BancoDeCompromissos implements Serializable, Iterable<Event>{

	private List<Event> bancoDeCompromissos;

	public List<Event> getBancoDeCompromissos() {
		return bancoDeCompromissos;
	}

	public BancoDeCompromissos(){
		bancoDeCompromissos = new ArrayList<Event>();
	}
	
	public BancoDeCompromissos(BancoDeCompromissos novoBanco){
		bancoDeCompromissos = new ArrayList<Event>();
		bancoDeCompromissos.addAll(novoBanco.getBancoDeCompromissos());
	}

	public boolean inserirCompromisso(Event novoCompromisso){ // insere cliente na lista
		if(!contem(novoCompromisso)) return bancoDeCompromissos.add(novoCompromisso);
		else return false;
	}

	public  boolean contem(Event compromisso){ //Busca cliente na lista de clientes

		for(Event aux:bancoDeCompromissos){
			if(aux.equals(compromisso))
				return true;
		}    
		return false;
	}
        
       public boolean excluirCompromisso(Event excluirCompromisso) { //Exclui compromisso

        for (Event aux : bancoDeCompromissos) {
            if (aux.equals(excluirCompromisso)){
                bancoDeCompromissos.remove(aux);
                
                return true;
            }
        }
        return false;
    }
        
       public boolean excluirCompromisso(int ID) { //Exclui compromisso

        for (Event aux : bancoDeCompromissos) {
            if (aux.getID()==ID){
                return bancoDeCompromissos.remove(aux);
            }
        }
        return false;
    }

	/*public Cliente getCompromisso(String email){
		for(Cliente cliente:bancoDeClientes)
			if(cliente.getEmail().equals(email))
				return cliente;
		return null;
	}*/

	@Override
	public Iterator<Event> iterator() {
		return bancoDeCompromissos.iterator();
	}

	public int size(){
		return bancoDeCompromissos.size();
	}

}
